<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('【请填写功能名称】列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>订单地址：</p>
                                <input type="text" name="customerOrderAddress"/>
                            </li>
                            <li>
                                <p>客户id：</p>
                                <input type="text" name="customerId"/>
                            </li>
                            <li>
                                <p>总价：</p>
                                <input type="text" name="customerOrderTotalPrice"/>
                            </li>
                            <li class="select-time">
                                <p>期望到货时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginCustomerOrderExpectArrivalDatetime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endCustomerOrderExpectArrivalDatetime]"/>
                            </li>
                            <li>
                                <p>订单状态：</p>
                                <select name="customerOrderStatus">
                                    <option value="补货中">补货中</option>
                                </select>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:order:edit')}]];
        var prefix = ctx + "system/order";

        $(function() {
            var options = {
                url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                modalName: "【请填写功能名称】",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'customerOrderId', 
                    title : '客户订单id',
                    visible: false
                },
                {
                    field : 'customerOrderAddress', 
                    title : '订单地址'
                },
                {
                    field : 'customerOrderStartDatetime', 
                    title : '下单时间'
                },
                {
                    field : 'customerId', 
                    title : '客户id'
                },

                 //  十分士大夫广泛大使馆反对
                {
                    field : 'productName',
                    title : '商品名称'
                },
                {
                    field : 'customerOrderItemNumber',
                    title : '商品数量'
                },
                {
                    field : 'productUnit',
                    title : '商品单位'
                },
                {
                    field : 'productPrice',
                    title : '商品单价'
                },
                 //风格反对广泛大使馆大使馆

                {
                    field : 'customerOrderTotalPrice',
                    title : '总价'
                },
                {
                    field : 'customerOrderExpectArrivalDatetime', 
                    title : '期望到货时间'
                },
                {
                    field : 'customerOrderStatus', 
                    title : '订单状态'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + '" href="javascript:void(0)" onclick="cuccessorder(\'' + row.customerOrderId + ' , ' + row.customerOrderStartDatetime+ '\')"><i class="fa fa-edit"></i>查看补货情况</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        //接单实现
        function cuccessorder(customerOrders) {
            if (customerOrders) {

                var val = customerOrders.split(",");

                var r = confirm("是否查看补货情况?");
                if (r==true) {
                    $.post("/system/order/changeOneOrder",{customerOrderId:val[0],customerOrderStartDatetime:val[1]},function (result) {
                        if (result>0) {
                            $.post("/system/order/findOneOrder",{customerOrderId:val[0]},function (result) {

                                if (result.customerOrderStatus=="待出库"){
                                    alert("补货完成");
                                    location.reload();
                                }else if(result.customerOrderStatus=="补货中"){
                                    alert("正在补货中...");
                                }
                            });

                        }
                    })
                }
            }
        }
    </script>
</body>
</html>